package com.gdevelop.examples.demo.client;


import com.gdevelop.gwtxp.client.GwtXP;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.DecoratedTabPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

import java.util.Map;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Demo implements EntryPoint {
  public static final String GWTXP_XML_PACKAGE = "com.gdevelop.examples.demo.client.";
  
  /**
   * Application Constants.
   */
  public static final DemoConstants constants = (DemoConstants)GWT.create(DemoConstants.class);
  
  /**
   * Users List
   */
  public static final UserList users = UserList.createExampleData();

  /**
   * Controller map by its name.
   */
  public static final Map<String, GwtXP> controllerMap = (Map<String, GwtXP>)GWT.create(GwtXP.class);

  /**
   * Main panel source widget
   */
  public static final DecoratedTabPanel mainWindowSource = new DecoratedTabPanel();

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    GWT.create(DemoInfo.class);
    
    GwtXP gwtxp = controllerMap.get(GWTXP_XML_PACKAGE + "MainWindow.gwtxp.xml");
    RootPanel.get().add((Widget)gwtxp.getGUI());
    
    mainWindowSource.setWidth("100%");
    RootPanel.get().add(mainWindowSource);
    HTML sourceWidget = new HTML();
    mainWindowSource.add(sourceWidget, Demo.constants.source());
    ContentWidget.requestSourceContents(DemoConstants.DST_SOURCE_EXAMPLE + 
                            "MainWindow.gwtxp.xml.html", sourceWidget, null);
    mainWindowSource.selectTab(0);
  }
}
